var shareObj = {
    el: '#pageApp',
    data: {
       categoryId:3,
       artileList:[],
       topTabBarData:{
        tab1:'生活服务',
        tab2:'物有所用',
        searchType:2
       }
    },
    components:{
      'top-tab-bar':topTabBar
    },
    methods: {
      getTinyArticleList:function(){
        var _this = this;
        g.ajax({
          type: 'GET',
          url: g.url.format('/api/author/getTinyArticleList'),
          data:{ text: "", categoryId: _this.categoryId},
          success: function (result) {
             _this.setArticleList(result.data);   
          }
        });
      },
      setArticleList:function(data){
        var _this = this;
        var nodeTimeArr = [];
        data.forEach(function (item) {
          item.imgs = item.img.split(',');
          item.img = g.url.imgFormat(item.imgs[0]);
          item.nodeTime = g.getDateDiff(item.time);
          if(nodeTimeArr.indexOf(item.nodeTime ) >= 0){
            item.showNodeTime = false;
          }else{
            nodeTimeArr.push(item.nodeTime);
            item.showNodeTime = true;
          }
          _this.artileList.push(item);
        });
      },
      toggleTab:function(index){
        if(index == 1){
          this.categoryId = 3;
        }
        if(index == 2){
          this.categoryId = 4;
        }
        this.artileList.splice(0);
        this.getTinyArticleList();
      },
      toArticleDetail:function(id){
        g.window.openNew(g.url.urlHref('/page/articleDetail.html?id='+ id +'&type=2'));
      },
      toShare:function(){
        g.window.openNew(g.url.urlHref('/page/submitShare.html'));
      }
    },
    mounted:function () {
      this.getTinyArticleList();
    
    }
};
var initPage = function(){
  new Vue(shareObj);
};
